home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / faq < prev    next >
Encoding:
Text File  |  2001-02-08  |  35.3 KB  |  931 lines

  1. This file was generated automatically from faq.texi.
  2. DO NOT CHANGE THIS FILE MANUALLY!
  3.  
  4. The GNU Pascal Frequently Asked Questions List, Edition 0.9, August 2000
  5. ************************************************************************
  6.  
  7.    This document is a part of the GPC documentation. To make, copy and
  8. distribute modified versions of this document please see the GPC
  9. documentation.
  10.  
  11.    This is the Frequently Asked Questions List (FAQ) for GNU Pascal. If
  12. the FAQ and the documentation do not help you, you have detected a
  13. *bug* in it which should be reported, *Note Mailing List::.  Please
  14. really do it, so we can improve the documentation.
  15.  
  16. 1 GNU Pascal
  17. ************
  18.  
  19. 1.1 What and why?
  20. =================
  21.  
  22.    The purpose of the GNU Pascal project is to produce a Pascal
  23. compiler (called GNU Pascal or GPC) which
  24.  
  25.    * combines the clarity of Pascal with powerful tools suitable for
  26.      real-life programming,
  27.  
  28.    * supports both the Pascal standard and the Extended Pascal standard
  29.      as defined by ISO, ANSI and IEEE (ISO 7185:1990, ISO/IEC
  30.      10206:1991, ANSI/IEEE 770X3.160-1989),
  31.  
  32.    * supports other Pascal standards (UCSD Pascal, Borland Pascal,
  33.      Pascal-SC) in so far as this serves the goal of clarity and
  34.      usability,
  35.  
  36.    * may be distributed under GNU license conditions, and
  37.  
  38.    * can generate code for and run on any computer for which the GNU C
  39.      compiler can generate code and run on.
  40.  
  41.    Pascal was originally designed for teaching. GNU Pascal provides a
  42. smooth way to proceed to challenging programming tasks without learning
  43. a completely different language.
  44.  
  45.    The current release implements Standard Pascal (ISO 7185, level 1),
  46. a large subset of Extended Pascal (ISO 10206, aiming for full
  47. compliance), is highly compatible to Borland Pascal (version 7.0) with
  48. some Delphi extensions, and provides a lot of useful GNU extensions.
  49.  
  50. 1.2 What is the current version?
  51. ================================
  52.  
  53.    Prior to July 2000 releases were several months apart. Since then
  54. there has been a new release every few days, available as a source
  55. archive or from a CVS server from the GPC web site,
  56. `http://home.pages.de/~GNU-Pascal/'.
  57.  
  58.    For details about new features, see the section `News' on the web
  59. site. On bugs fixed recently, see the `Done' section of the To-Do list
  60. (on the same web site).
  61.  
  62.    GPC uses GCC as a back-end. Patches for GCC 2.8.1 and GCC 2.95.x are
  63. provided but it is recommended that you use GCC 2.95.x.
  64.  
  65. 1.3 Is it compatible with Turbo Pascal (R)?
  66. ===========================================
  67.  
  68.    GPC is not a drop-in replacement for Borland's Turbo Pascal (R).
  69. Almost all BP language features are supported. Notable exceptions are
  70. the string format (as discussed below), or the `Mem' and `Port' pseudo
  71. arrays, though replacement functions for the latter on x86 platforms
  72. exist in the `Ports' unit.
  73.  
  74.    Almost all of BP's run time library is supported in GPC, either by
  75. built-in compiler features or in units with the same names as their BP
  76. counterparts.
  77.  
  78.    For details about the compatibility, the few remaining
  79. incompatibilities and some useful alternatives to BP features, see the
  80. `Borland Pascal' chapter in the GPC Manual.
  81.  
  82. 1.4 Which platforms are supported by GNU Pascal?
  83. ================================================
  84.  
  85.    GPC uses the GCC backend, so it should run on any system that is
  86. supported by GNU CC. This includes a large variety of Unix systems,
  87. MS-DOS, OS/2 and Win32. A full list of platforms supported by GCC can
  88. be found in the file `INSTALL' of the GCC distribution. Not all of
  89. these have actually been tested, but it is known to run on these
  90. platforms:
  91.  
  92. ix86-linux                    (Linux 2.x, ELF)
  93. i486-linuxaout                
  94. i486-linuxoldld               
  95. i386-freebsd1.2.0             
  96. AIX 4.2.1                     
  97. AIX 4.3                       
  98. DJGPP V2                      (Dos)
  99. EMX 0.9B                      (OS/2, Dos)
  100. Cygwin32 beta20 and higher    (MS-Windows95/98, MS-Windows NT)
  101. Mingw32                       (MS-Windows95/98, MS-Windows NT)
  102. mips-sgi-irix5.3              
  103. sun-sparc-sunos4.1.4          
  104. sparc-sun-solaris2.x          
  105. sun-sparc-solaris 2.5.1       
  106. sun-sparc-solaris 2.6         
  107. sun-sparc-solaris 7           
  108. alpha-unknown-linux           
  109. alphaev56-dec-osf4.0d         
  110.  
  111.    *OK people - send us your success stories, with canonical machine
  112. name!*
  113.  
  114. 2 Installing GPC
  115. ****************
  116.  
  117.    You find the most up-to-date installation instructions in the GPC
  118. Manual or the file `INSTALL' in source distributions, or on the GPC web
  119. site.
  120.  
  121.    The following sections describe things you might need or want to
  122. install besides GPC itself.
  123.  
  124. 2.1 What to read next
  125. =====================
  126.  
  127.    After installing GPC, please check the files in the directory
  128. `/usr/local/doc/gpc':
  129.  
  130. `README'       General Information about GPC
  131. `FAQ'          This FAQ :-)
  132. `NEWS'         Changes since the last release
  133. `LIBS'         Libraries used by some GPC units
  134. `BUGS'         How to report bugs, about the Test Suite
  135. `AUTHORS'      List of GPC authors
  136. `COPYING'      The GNU General Public License
  137.  
  138. 2.2 Which components do I need to compile Pascal code?
  139. ======================================================
  140.  
  141.    A complete Pascal compiler system should at least have:
  142.  
  143.   1. The actual compiler, GPC.
  144.  
  145.   2. An editor, assembler, linker, librarian and friends.
  146.  
  147.   3. A C library. If you have a working C compiler, you already have
  148.      this.
  149.  
  150.   4. A debugger, if you want to debug your programs.
  151.  
  152.    For most people, the GNU binutils and GNU debugger (`gdb') are a
  153. good choice, although some may prefer to use vendor specific tools.
  154.  
  155. 2.3 How do I debug my Pascal programs?
  156. ======================================
  157.  
  158.    To debug your programs, (a) GNU Pascal must be able to generate
  159. executables with debug info for your platform, and (b) you must have a
  160. debugger which understands this.
  161.  
  162.    * If `gpc -g -o hello hello.p' says:
  163.           gpc: -g not supported for this platform
  164.      then GPC is unable to generate debugging info. Usually, installing
  165.      `gas' (part of GNU binutils) instead of your system's assembler
  166.      can overcome this. When you configure the GCC used for GPC, specify
  167.      `--with-gnu-as', and possibly `--with-gnu-ld' and/or
  168.      `--with-stabs'. More information can be found in the `INSTALL'
  169.      file in the GNU CC source directory.
  170.  
  171.    * Your system's debugger may not understand the debug info generated
  172.      by GNU tools. In this case, installing `gdb' may help.
  173.  
  174.    The bottom line: if you can debug GCC compiled programs, you should
  175. be able to do this with GPC too.
  176.  
  177.    The GNU debugger (`gdb') currently does not have a "Pascal" mode, so
  178. it is unable to display certain Pascal structures etc. When debugging,
  179. please note that the Initial Letter In Each Identifier Is In Upper Case
  180. And The Rest Are In Lower Case. If you want to display variable `foo'
  181. in the debugger, type `show Foo' or `display Foo' instead.
  182.  
  183.    Although `gdb' is an excellent debugger, it's user interface is not
  184. everybody's preference. If you like to debug under X11, please refer to
  185. the comp.windows.x FAQ: "Where can I get an X-based debugger?" at:
  186. `http://www.cis.ohio-state.edu/hypertext/faq/usenet/x-faq/part6/faq-doc-2.html'
  187.  
  188.    Some useful frontends include: XXGDB, tGDB and XWPE. See:
  189. `http://www.ee.ryerson.ca:8080/~elf/xapps/Q-IV.html'
  190.  
  191.    Very nice, but resource consuming is the Motif based DDD:
  192. `http://sol.ibr.cs.tu-bs.de/softech/ddd/'
  193.  
  194.    Furthermore, RHIDE (*note IDE::) contains built-in debugging suport,
  195. similar to the IDE of BP.
  196.  
  197. 2.4 What additional libraries should I have?
  198. ============================================
  199.  
  200.    You will need certain additional libraries when you compile some of
  201. the units. These can be found in the directory
  202. `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/libs/'.
  203.  
  204.    Currently, there are the following libraries:
  205.  
  206. gmp
  207.      Arithmetic for integers, rationals and real numbers with arbitrary
  208.      size and precision. Used by the GMP unit.
  209.  
  210. rx
  211.      Regular expression matching and substitution. Used by the RegEx
  212.      unit.
  213.  
  214. ncurses
  215. PDCurses
  216.      Screen handling. Used by the CRT unit. Depending on your system,
  217.      you have the following choices:
  218.  
  219.      Unix: You can compile terminal applications with ncurses and
  220.      applications that run in an X11 window with PDCurses (though
  221.      terminal applications can, of course, also run in an xterm under
  222.      X11). ncurses is used by default. If you want to use PDCurses
  223.      (a.k.a. XCurses), give the option `-DX11' when compiling CRT.
  224.  
  225.      Dos with DJGPP and MS-Windows with mingw: Only PDCurses is
  226.      available and will be used by default.
  227.  
  228.      MS-Windows with Cygwin: PDCurses and ncurses are available.
  229.      PDCurses is used by default. If you want to use ncurses, give the
  230.      option `-DUSE_NCURSES' when compiling CRT.
  231.  
  232.      Other systems: Please see the `README's and installation
  233.      instructions of PDCurses and ncurses to find out which one(s) can
  234.      be built on your system. See the conditionals at the end of
  235.      crt.inc and crtc.h (and change them if necessary) on which library
  236.      is used by default.
  237.  
  238. ElectricFence
  239.      This library is not used by any GPC unit. It is a debugging tool to
  240.      assist you in finding memory allocation bugs. To use it, just link
  241.      it to your program, either on the command line (`-lefence') or in
  242.      the source code (`{$L efence}') which you might want to put into
  243.      an `{$ifdef DEBUG}' or similar since using libefence is only
  244.      recommended for debugging.
  245.  
  246.    The source code of the libraries is available in the main `libs'
  247. directory. Most libraries come with one or several patches which should
  248. be applied before compiling them.
  249.  
  250.    Binaries for some platforms are available in the `binary/PLATFORM'
  251. subdirectories. If you compile the libraries for other platforms, be
  252. invited to make the binaries available to us for distribution on the
  253. FTP site.
  254.  
  255.    There are also the following files:
  256.  
  257. `terminfo-linux.tar.gz'
  258.      This is a patch to enable ncurses programs to make use of the
  259.      ability of Linux 2.2 and newer kernels to produce a block cursor
  260.      when needed. The present patch can be installed without recompiling
  261.      anything, just by copying some files into place. More details can
  262.      be found in the `README' file included in this archive. The patch
  263.      will not do any harm on older kernels. Please note that *not* only
  264.      on Linux machines it is useful to install the patch. Installing
  265.      them on any other machine will allow users who telnet in from a
  266.      Linux console to profit from the block cursor capability. Besides,
  267.      some Unix systems have installed older Linux terminfo entries or
  268.      none at all, so it's a good thing, anyway, to give them a current
  269.      version. The patch is included in the terminfo database of ncurses
  270.      5.0, so if you install ncurses 5.0 (source or binary), you don't
  271.      need to get the patch separately. But you can install it on a
  272.      system with an older ncurses version if you don't feel like
  273.      upgrading ncurses altogether.
  274.  
  275. `tsort-2.9i.zip'
  276.      A little utility (extracted from util-linux-2.9i, but not Linux
  277.      specific), needed for the configuration of the rx library. You
  278.      need it only if you compile rx yourself (and if it's not already
  279.      present on your system), not when using a rx binary.
  280.  
  281. 2.5 Contributed units
  282. =====================
  283.  
  284.    Several people have contributed units for GPC. They are usually
  285. announced on the mailing list, *Note Mailing List::. Here's a selection:
  286.  
  287.    * Nicola Girardi wrote a unit which you can use to interface Svgalib.
  288.      You can read a mini-FAQ about it at
  289.      `http://ages.dida.physik.uni-essen.de/~nicola/', complete with
  290.      links to download the unit via http or ftp. If you want to download
  291.      the unit directly, get `svgalib-gpc-20000216.tar.gz' from
  292.      `ftp://agnes.dida.physik.uni-essen.de/home/nicola/'.
  293.  
  294.    * Prof. Abimbola A. Olowofoyeku ("The African Chief") wrote a
  295.      Delphi-compatible (though a few routines are still missing)
  296.      `SysUtils' unit. It has been tested under Cygwin, Mingw, Linux
  297.      (Mandrake 7.0), and Solaris 7. It can be downloaded from
  298.      `ftp://agnes.dida.physik.uni-essen.de/home/chief/sysutils-20000725.zip'.
  299.  
  300.    * Eike Lange wrote units to access MySql, GNU DBM and PostgreSQL data
  301.      bases. As of this writing (Aug 2000), they are in Alpha stage. They
  302.      can be downloaded from
  303.      `ftp://agnes.dida.physik.uni-essen.de/home/lange/'.
  304.  
  305. 2.6 Can you recommend an IDE?
  306. =============================
  307.  
  308.    Users of Borland Pascal may wonder if there's a replacement for the
  309. IDE (Integrated Development Environment). Here's a few suggestions:
  310.  
  311.    * (X)Emacs. Some people think it's the answer to the question of
  312.      Life, the Universe and Everything, others decide it's uGNUsable.
  313.      Available from your friendly GNU mirror and most distributions.
  314.  
  315.    * RHIDE. DJGPP users might want to try RHIDE. The latest (beta)
  316.      release is compatible with GNU Pascal and allows stepping, tracing
  317.      and watching like Borland's IDE. It can be downloaded from
  318.      `http://www.tu-chemnitz.de/~sho/rho/rhide/rhide.html'.
  319.  
  320.    * PENG. It's not free software, but it was written with GPC.  It's
  321.      very similar to Borland's IDE, but with many extensions.  Binaries
  322.      for DJGPP, Linux and Solaris can be downloaded from
  323.      `http://fjf.gnu.de/peng.html'.
  324.  
  325.    * XWPE is another imitation of the Borland IDE, so users of Borland
  326.      Pascal may find it a good alternative.
  327.  
  328. 3 GNU Pascal on the DJGPP (MS-DOS) platform
  329. *******************************************
  330.  
  331.    This chapter discusses some potential problems with GNU Pascal on
  332. MS-DOS, using DJGPP.
  333.  
  334. 3.1 What is DJGPP?
  335. ==================
  336.  
  337.    The following paragraph is from the site
  338. `http://www.delorie.com/djgpp/':
  339.  
  340.    DJGPP is a complete 32-bit C/C++ development system for Intel 80386
  341. (and higher) PCs running DOS. It includes ports of many GNU development
  342. utilities. The development tools require a 80386 or newer computer to
  343. run, as do the programs they produce. In most cases, the programs it
  344. produces can be sold commercially without license or royalties.
  345.  
  346. 3.2 If you need more information
  347. ================================
  348.  
  349.    GPC/DJGPP is a DJGPP V2 application, and most of the DJGPP
  350. documentation applies for GPC too. A great source of information is the
  351. DJGPP FAQ: `http://www.delorie.com/djgpp/v2faq/230b.zip'
  352.  
  353.    Another place to look for DJGPP documentation is the DJGPP Knowledge
  354. Base, at this URL: `http://www.delorie.com/djgpp/doc/kb/'
  355.  
  356. 3.3 What do I download?
  357. =======================
  358.  
  359.    As discussed in *Note Components::, other than GPC itself, you need
  360. an assembler, linker and friends, a C library and possibly a debugger.
  361. The site `http://www.delorie.com/djgpp/' recommended the following
  362. files and they will help you find a mirror:
  363.  
  364. `v2/djdev203.zip'       (C library)
  365. `v2gnu/bnu2951b.zip'    (assembler, ....)
  366. `v2gnu/gcc2952b.zip'    (gcc)
  367. `v2gnu/gdb418b.zip'     (debugger)
  368. `v2gnu/mak379b.zip'     (make)
  369. `v2gnu/txi40b.zip'      (texi)
  370.  
  371.    This list is about 10 MB not counting GPC. You can use a binary
  372. version of GPC from agnes.
  373.  
  374. 3.4 How do I install the compiler?
  375. ==================================
  376.  
  377.    If you don't have DJGPP installed on your harddisk, create a
  378. directory for GNU Pascal (`c:\gpc'), and unzip the archives.  Make sure
  379. you preserve the directory structure (use `pkunzip -d'). Now, add the
  380. directory where `gpc.exe' lives (`c:\gpc\bin') to your path and set the
  381. DJGPP environment variable to point to your `djgpp.env' file:
  382.  
  383.      set DJGPP=c:\gpc\djgpp.env
  384.  
  385.    Then, add this to your `djgpp.env' file:
  386.  
  387.      ---------------------------------------------------------
  388.      [gpcpp]
  389.      C_INCLUDE_PATH=%/>;C_INCLUDE_PATH%%DJDIR%/lang/pascal;%DJDIR%/include
  390.      
  391.      [gpc]
  392.      COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin
  393.      LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib;%DJDIR%/contrib/grx20/lib
  394.      ---------------------------------------------------------
  395.  
  396.    The binary distribution should come with a `djgpp.env' which is
  397. already modified, so you may not have to do this.
  398.  
  399.    The GPC online documentation is in GNU info format; you need the
  400. Info reader (`txi390b.zip') to read it, or use the built-in Info reader
  401. of the RHIDE or PENG IDE. To add the GPC documentation to the info
  402. directory file, edit the `c:\gpc\info\dir' file, and locate this
  403. section:
  404.  
  405.      ---------------------------------------------------------
  406.      * GCC: (gcc.inf).
  407.      The GNU C, C++, and Objective-C Compiler
  408.      
  409.      * GDB: (gdb.inf).
  410.      The GNU Debugger (gdb and gdb-dpmi).
  411.      
  412.      ---------------------------------------------------------
  413.  
  414.    To add GPC, change it to look like this:
  415.  
  416.      ---------------------------------------------------------
  417.      * GCC: (gcc.inf).
  418.      The GNU C, C++, and Objective-C Compiler
  419.      
  420.      * GPC: (gpc.inf).
  421.      The GNU Pascal Compiler
  422.      
  423.      * GDB: (gdb.inf).
  424.      The GNU Debugger (gdb and gdb-dpmi).
  425.      
  426.      ---------------------------------------------------------
  427.  
  428.    Specific information for low-memory conditions and more can be found
  429. in the DJGPP FAQ and documentation.
  430.  
  431. 3.5 I cannot read the Info documentation!
  432. =========================================
  433.  
  434.    To read the Info documentation, you need the `info' program from
  435. `txi390b.zip' or an IDE like RHIDE or PENG.
  436.  
  437. 3.6 GPC says: no DPMI
  438. =====================
  439.  
  440.    You don't have a DPMI server installed, and DJGPP v2 requires it to
  441. run. You can either use one of the commercial DPMI servers (e.g., run
  442. `gpc' in a DOS box under MS-Windows) or download and install CWSDPMI
  443. (`csdpmi3b.zip') which is a free DPMI server written for DJGPP.
  444.  
  445. 3.7 I have troubles with assembly code
  446. ======================================
  447.  
  448.    The GNU Assembler (`as.exe'), or `gas', called by GCC accepts "AT&T"
  449. syntax which is different from "Intel" syntax.  Differences are
  450. discussed in section 17.1 of the DJGPP FAQ.
  451.  
  452.    A guide is available which was written by Brennan Mr. Wacko
  453. Underwood <brennan@mack.rt66.com> and describes how to use inline
  454. assembly programming with DJGPP, at this URL:
  455. `http://www.rt66.com/~brennan/djgpp/djgpp_asm.html'
  456.  
  457.    There's also a GPC assembler tutorial at
  458. `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/contrib/gpcasm.zip'
  459.  
  460.    Section 17.3 of the DJGPP FAQ discusses some methods to convert
  461. "Intel" syntax to "AT&T" syntax.
  462.  
  463. 3.8 Tell me how to do DPMI, BIOS and other DOS related things.
  464. ==============================================================
  465.  
  466.    DPMI, BIOS and other functions are no different than other system
  467. functions. Refer to the GPC Manual on how to access your system's
  468. C-library. This small example shows how to use DPMI, copying some
  469. structures and function prototypes of `<dpmi.h>':
  470.  
  471.      program DPMIDemo;
  472.      
  473.      { Only for DJGPP }
  474.      
  475.      {$X+}
  476.      
  477.      { `Byte' is `unsigned char' in C,
  478.        `ShortCard' is `unsigned short' in C,
  479.        `MedCard' is `unsigned long' in C,
  480.        `Word' is `unsigned' in C,
  481.        etc. (all these types are built-in). }
  482.      
  483.      type
  484.        TDpmiVersionRet = record
  485.          Major      : Byte;
  486.          Minor      : Byte;
  487.          Flags      : ShortCard;
  488.          CPU        : Byte;
  489.          Master_PIC : Byte;
  490.          Slave_PIC  : Byte;
  491.        end;
  492.      
  493.      type
  494.        TDpmiFreeMemInfo = record
  495.          Largest_Available_Free_Block_In_Bytes,
  496.          Maximum_Unlocked_Page_Allocation_In_Pages,
  497.          Maximum_Locked_Page_Allocation_In_Pages,
  498.          Linear_Address_Space_Size_In_Pages,
  499.          Total_Number_Of_Unlocked_Pages,
  500.          Total_Number_Of_Free_Pages,
  501.          Total_Number_Of_Physical_Pages,
  502.          Free_Linear_Address_Space_In_Pages,
  503.          Size_Of_Paging_File_Partition_In_Pages,
  504.          Reserved1,
  505.          Reserved2,
  506.          Reserved3 : MedCard;
  507.        end;
  508.      
  509.      function DpmiGetVersion (var Version: TDpmiVersionRet): Integer;
  510.               asmname '__dpmi_get_version';
  511.      
  512.      function DpmiGetFreeMemoryInformation
  513.               (var MemInfo: TDpmiFreeMemInfo): Integer;
  514.               asmname '__dpmi_get_free_memory_information';
  515.      
  516.      var
  517.        Version: TDpmiVersionRet;
  518.        MemInfo: TDpmiFreeMemInfo;
  519.      
  520.      begin
  521.        if DpmiGetVersion (Version) = 0 then
  522.          begin
  523.            WriteLn ('CPU type :       ', Version.cpu, '86');
  524.            WriteLn ('DPMI major :       ', Version.Major);
  525.            WriteLn ('DPMI minor :       ', Version.Minor);
  526.          end
  527.        else
  528.          WriteLn ('Error in DpmiGetVersion');
  529.        if DpmiGetFreeMemoryInformation (MemInfo) = 0 then
  530.          WriteLn ('Free DPMI memory : ',
  531.                   MemInfo.Total_Number_Of_Free_Pages, ' pages.')
  532.        else
  533.          WriteLn ('Error in DpmiGetMemoryInformation');
  534.      end.
  535.  
  536. 3.9 I got an exception when accessing an `array [1 .. 4000000] of Byte'.
  537. ========================================================================
  538.  
  539.    Per default, the maximum stack size of a DJGPP application is 256K.
  540. If you need more, you have to adjust it with the stubedit program, i.e.:
  541.  
  542.      stubedit your_app.exe minstack=5000K
  543.  
  544.    Another way is to add the following code to your program to define a
  545. minimum stack size (here: 2 MB). This value will be honored even if a
  546. user sets a lower value by using stubedit, so this method might be a
  547. little safer.
  548.  
  549.    Note: The syntax given here is valid for GPC releases of May 2000
  550. and newer.
  551.  
  552.      {$ifdef DJGPP}
  553.      const
  554.        MinStackSize : Cardinal = $200000; asmname '_stklen';
  555.      {$endif}
  556.  
  557.    Still, it might be a good idea to use pointers for large structures,
  558. and allocate the memory at runtime.
  559.  
  560. 4 Strings
  561. *********
  562.  
  563. 4.1 What's this confusion about strings?
  564. ========================================
  565.  
  566.    Turbo Pascal strings have a length byte in front. Since a byte has
  567. the range 0 .. 255, this limits a string to 255 characters. However,
  568. the Pascal string schema, as defined in section 6.4.3.3.3 of the
  569. ISO-10206: 1990 Extended Pascal standard, is a schema record:
  570.  
  571.      type
  572.        String (Capacity : Integer) = record
  573.          Length : 0 .. Capacity;
  574.          String : packed array [1 .. Capacity + 1] of Char
  575.        end;
  576.  
  577.    The `+ 1' is a GPC extension to make it feasible to automatically
  578. add the `#0' terminator when passing or assigning them to CStrings.
  579. Thus at the expense of a little added complexity (must declare
  580. capacity, don't use `GetMem' without explicit initialization of the
  581. `Capacity' field, and the additional space requirement) you can now
  582. have very long strings.
  583.  
  584. 4.2 Overlaying strings in variant records
  585. =========================================
  586.  
  587.    Q: Should the different variants in a variant record overlay in the
  588. same memory? Previous Pascals I have used have guaranteed this, and
  589. I've got low-level code that relies on this. The variants are not the
  590. same length, and they are intended not to be.
  591.  
  592.    A: No, this is intentional so that the discriminants are not
  593. overwritten, and they can be properly initialized in the first place.
  594. Consider:
  595.  
  596.      record
  597.      case Boolean of
  598.        False: (s1 : String (42));
  599.        True:  (s2 : String (99));
  600.      end;
  601.  
  602.    If the strings would overlay, in particular their discriminants
  603. would occupy the same place in memory. How should it be initialized?
  604. Either way, it would be wrong for at least one of the variants...
  605.  
  606.    So, after a discussion in comp.lang.pascal.ansi-iso where this topic
  607. came up concerning file variables (which also require some automatic
  608. initialization and finalization), we decided to do this in GPC for all
  609. types with automatic initialization and finalization (currently files
  610. and schemata, in the future this might also be Delphi compatible
  611. classes and user-defined initialized and finalized types), since the
  612. standard does not guarantee variants to overlay, anyway...
  613.  
  614.    There are two ways in GPC to get guaranteed overlaying (both
  615. non-standard, of course, since the standard does not assume anything
  616. about internal representations; both BP compatible), `absolute'
  617. declarations and variable type casts. E.g., in order to overlay a byte
  618. array `b' to a variable `v':
  619.  
  620.      var
  621.        b: array [1 .. SizeOf (v)] of Byte absolute v;
  622.  
  623.    Or you can use type-casting:
  624.  
  625.      type
  626.        t = array [1 .. SizeOf (v)] of Byte;
  627.  
  628.    then `t (v)' can be used as a byte array overlayed to `v'.
  629.  
  630. 4.3 Why does `s[0]' not contain the length?
  631. ===========================================
  632.  
  633.    Q: In standard Pascal you expect `s[1]' to align with the first
  634. character position of `s' and thus one character to the left is the
  635. length of `s'. Thus `s[0]' is the length of `s'.  True?
  636.  
  637.    A: This holds for UCSD/BP strings (which GPC does not yet implement,
  638. but that's planned). The only strings Standard Pascal knows are arrays
  639. of char without any length value.
  640.  
  641.    GPC also supports Extended Pascal string schemata (*note String
  642. schema::), but they also don't have a length byte at "position 0", but
  643. rather a `Length' field (which is larger than one byte).
  644.  
  645. 4.4 Support for BP compatible short strings
  646. ===========================================
  647.  
  648.    Q: Two different kinds of strings with the same name - `String' -
  649. does make a bit of confusion. Perhaps the oldstyle strings could be
  650. renamed `short string' ?
  651.  
  652.    A: When we implement the short strings, we'll have to do such a
  653. distinction. Our current planning goes like this:
  654.  
  655.    `String (N)': string schema (EP compatible)
  656.  
  657.    `String [N]': short string (UCSD/BP compatible, where N must be <=
  658. 255)
  659.  
  660.    `String': dependent on flags, by default undiscriminated schema, but
  661. in BP mode (or with a special switch) short string of capacity 255
  662. (UCSD/BP compatible).
  663.  
  664.    Q: So when will these short strings be available?
  665.  
  666.    A: It's been planned for over a year. The delay has been caused by
  667. more pressing problems.
  668.  
  669. 4.5 What about C strings?
  670. =========================
  671.  
  672.    A C string (`char *') is an array of char, terminated with a `#0'
  673. char.
  674.  
  675.    C library functions require C, not Pascal style string arguments.
  676. However, Pascal style strings are automatically converted to C style
  677. strings when passed to a routine that expects C style strings. This
  678. works only if the routine reads from the string, not if it modifies it.
  679.  
  680.    E.g., this is how you could access the `system()' call in your C
  681. library (which is not necessary anymore, since `Execute' is already
  682. built-in):
  683.  
  684.      program SysCall;
  685.      
  686.      function System (Name : CString): Integer; asmname 'system';
  687.      
  688.      var
  689.        Result : Integer;
  690.      
  691.      begin
  692.        Result := System ('ls -l');
  693.        WriteLn ('system() call returned : ', Result)
  694.      end.
  695.  
  696.    You could use the type `PChar' instead of `CString'. Both `CString'
  697. and `PChar' are predefined as `^Char' - though we recommend `CString'
  698. because it makes it clearer that we're talking about some kind of
  699. string rather than a single character.
  700.  
  701.    A lot of library routines in Pascal for many applications exist in
  702. the GPC unit and some other units. Where available, they should be
  703. preferred (e.g. `Execute' rather than `system()', and then you won't
  704. have to worry about `CString's.)
  705.  
  706.    Do *not* pass a C style string as a `const' or `var' argument if the
  707. C prototype says `const char *' or you will probably get a segfault.
  708.  
  709. 5 Getting Help
  710. **************
  711.  
  712.    Please read the GPC Manual (info files or other formats) as well as
  713. the `README' and `BUGS' files that come with GPC (usually installed in
  714. directory `/usr/local/doc/gpc'), plus other docs that might help (the
  715. DJGPP FAQ if you use DJGPP, etc.) before you send email to the
  716. maintainers or mailing list.
  717.  
  718.    In particular, the `BUGS' file contains information on how to submit
  719. bug reports in the most efficient way.
  720.  
  721.    The `Support' chapter of the GPC Manual tells you where to find more
  722. information about GPC and how to contact the GPC developers.  The
  723. following information is from this chapter.
  724.  
  725. 5.1 The GPC Mailing List
  726. ========================
  727.  
  728.    There is a mailing list devoted to GNU Pascal. You can write to the
  729. mailing list, e.g. if you have problems installing GPC or if you found
  730. a problem with GPC (please see *Note Reporting Bugs::). You can also
  731. use it to discuss suggestions for improving GPC and, most welcome, to
  732. offer your help or contribute code, documentation or other work. Mails
  733. to the list should be in English.
  734.  
  735.    To subscribe to the mailing list, send the command
  736.      subscribe gpc your@email.address
  737.    in the body of a mail to <majordomo@gnu.de> (*not* to
  738. `gpc@gnu.de'!). The subject is ignored. (Please replace
  739. `your@email.address' with your real email address.) For more info, send
  740. a line `help' to <majordomo@gnu.de>.
  741.  
  742.    You can send a message to the mailing list by sending email to the
  743. list address <gpc@gnu.de> as if it were a person.
  744.  
  745.    To leave the mailing list, send the command
  746.      unsubscribe gpc your@email.address
  747.    to <majordomo@gnu.de>.
  748.  
  749.    There is also a (low-traffic) announce list, <gpc-announce@gnu.de>
  750. that you can subscribe to stay up-to-date. To subscribe to the list,
  751. write an email with
  752.      subscribe gpc-announce your@email.address
  753.    in the body to <majordomo@gnu.de>. If you like to announce a
  754. contribution, a service or an event related to GPC, you are invited to
  755. post to this list rather than `gpc@gnu.de', but please don't use the
  756. announce list for questions or discussions. Please note that all mail
  757. sent to the announce list is forwarded to the regular list, so you
  758. won't have to subscribe to both lists if you don't want to miss
  759. anything.
  760.  
  761. 5.2 The GPC Mailing List Archives
  762. =================================
  763.  
  764.    Perhaps your problem was already discussed on the list. There is a
  765. searchable archive of the mailing list on the WWW. It can be browsed or
  766. searched at `http://www.gnu.de/archive/wilma.cgi/gpc'.
  767.  
  768.    The archive of the GPC announcement list is at
  769. `http://www.gnu.de/archive/wilma.cgi/gpc-announce'.
  770.  
  771.    _Note:_ Currently, the search option is working fine. If you find it
  772. broken, please email me at <anja@drewitz.de>. Please don't mail a copy
  773. to the GPC list because I let procmail move all mails with `To: gpc...'
  774. and `Cc: gpc...' to a separate folder and would not see your mail for a
  775. long time. -- Anja
  776.  
  777.    This archive starts in June 1999. For older messages, see:
  778.  
  779.      `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/misc/gpc-list-1998.gz'
  780.      (513 kB)
  781.      `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/misc/gpc-list-1997.gz'
  782.      (995 kB)
  783.      `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/misc/gpc-list-1996.gz'
  784.      (154 kB)
  785.      `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/misc/gpc-list-1995.gz'
  786.      (42 kB)
  787.  
  788.    There is also a HTML version of these older archives at
  789. `http://www.iula.upf.es/altres/pub/gpc/list2html/gpclist.htm'.
  790.  
  791. 5.3 Newsgroups relevant to GPC
  792. ==============================
  793.  
  794.    To get support, you can also ask the Usenet newsgroups for help.
  795. There are several Pascal related newsgroups, but none is dedicated just
  796. to GNU Pascal, so use the one which is most appropriate for your
  797. problem. For general Pascal questions, we recommend the following one:
  798.  
  799. `news://comp.lang.pascal.misc'       Pascal in general and ungrouped
  800.                                      Pascals.
  801.  
  802.    Pascal syntax related questions may be appropriate in:
  803.  
  804. `news://comp.lang.pascal.ansi-iso'   Pascal according to ANSI and ISO
  805.                                      standards.
  806.  
  807.    The next newsgroup is a haven for beginners, answering questions
  808. that would apply to almost any Pascal. However, if you have a
  809. GPC-specific question don't post there - use the GPC mailing list.  And
  810. when in doubt use the GPC mailing list.
  811.  
  812. `news://comp.lang.pascal.borland'    Borland Pascal questions.
  813.  
  814.    Don't forget to give back what you have obtained. None of us is
  815. getting money for answering your questions (unless you pay us by
  816. yourself). Please do your part by answering the questions of others
  817. instead.
  818.  
  819. 5.4 Where to get individual support for GPC
  820. ===========================================
  821.  
  822.    GPC is free software and comes *without any warranty*.
  823.  
  824.    If you want to get professional support, you can hire an individual
  825. or a company for providing such a service.
  826.  
  827.    G-N-U GmbH (http://www.g-n-u.de) is doing large parts of the
  828. development of GNU Pascal. This company offers special support for GPC
  829. and can be contacted at <info@g-n-u.de>.
  830.  
  831.    More generally, to find a company or an individual who offers
  832. support and other consulting services for free software, look into the
  833. GNU Service Directory (http://www.gnu.org/prep/service.html).
  834.  
  835. 5.5 If the compiler crashes...
  836. ==============================
  837.  
  838.    If the compiler crashes, you have discovered a bug. A reliable
  839. compiler never crashes. To help the maintainers fix this bug, it is
  840. important that you send us a problem report.
  841.  
  842.    If you're on Unix, you can find out where the compiler crashed if
  843. you enable coredumps, then load the compiler (`gpc1') plus the core
  844. file in the debugger (`gdb /your_path_here/gpc1 core'), then type
  845. `backtrace' to get a stacktrace. Include this stacktrace in your bug
  846. report.
  847.  
  848. 5.6 How to report GPC bugs
  849. ==========================
  850.  
  851.    If you encounter a bug with GPC, please check whether it is one of
  852. the known bugs. If not, please report it to the GNU Pascal mailing list
  853. (*note Mailing List::). That way, they always reach the maintainers.
  854. Please note the following points.
  855.  
  856.    * Please send a description of the problem. Try to give as much
  857.      information as possible, with the full text of any error messages
  858.      encountered, or a description of how some output varies from the
  859.      expected output. Always specify the operating system type with
  860.      version and the machine type (try `uname -a' if unsure) as well as
  861.      the version of GPC as printed by `gpc -v'.
  862.  
  863.    * A good article on submitting bug reports can be found at either
  864.      `http://www.chiark.greenend.org.uk/~sgtatham/bugs.html' or
  865.      `http://freshmeat.net/news/2000/02/26/951627540.html'
  866.  
  867.  
  868.    If the problem is with the compiler itself, not an installation
  869. problem or something like this, please provide a test program to
  870. reproduce the problem, and note the following hints. You can also
  871. contribute test programs for features that are working in GPC to ensure
  872. they will not break in future releases.
  873.  
  874.    * The test program should be as short as possible, but *by all
  875.      means*, please send a *complete* program and *make sure* that it
  876.      still reproduces the problem before you send it. Too often, users
  877.      have sent code which contained obvious syntax errors far before
  878.      the actual problem, or just code fragments we could only make wild
  879.      guesses about. This is unproductive for us and doesn't help you
  880.      get your problem solved.
  881.  
  882.  
  883. 6 Miscellaneous
  884. ***************
  885.  
  886. 6.1 I want to contribute; where do I start?
  887. ===========================================
  888.  
  889.    If you want to contribute, please write to the mailing list, *Note
  890. Mailing List::.
  891.  
  892. 6.2 Where is the GNU Pascal FTP site? WWW?
  893. ==========================================
  894.  
  895.    The GPC homepage on the web is
  896. `http://home.pages.de/~GNU-Pascal/'.
  897.  
  898.    For now, this same page appears at
  899. `http://agnes.dida.physik.uni-essen.de/~gnu-pascal/'.
  900.  
  901.    The master FTP site for GNU Pascal is
  902. `agnes.dida.physik.uni-essen.de'.
  903.  
  904.    GNU Pascal related files can be found in
  905. `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/'.
  906.  
  907.    GPC To-Do list, latest features, fixed bugs:
  908. `http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html'
  909.  
  910. 6.3 About this FAQ
  911. ==================
  912.  
  913.    Current Maintainer: Russ Whitaker <russ@ashlandhome.net>
  914.  
  915.    This is the second incarnation of the GNU Pascal FAQ list. Comments
  916. about, suggestions for, or corrections to this FAQ list are welcome.
  917.  
  918.    This FAQ is based on GNU Pascal Frequently-Asked Questions List,
  919. Edition 0.4, for GPC version 2.0, November 1996 by J.J. van der Heijden
  920. <j.j.vanderheijden@student.utwente.nl>.
  921.  
  922.    Please make sure to include in your mail the version number of the
  923. document to which your comments apply (you can find the version at the
  924. beginning of this FAQ list).
  925.  
  926.    Many people have contributed to this FAQ, only some of them are
  927. acknowledged above. Much of the info in, and inspiration for this FAQ
  928. list was taken from the GPC mailing list traffic, so you may have
  929. (unbeknownst to you) contributed to this list.
  930.  
  931.